home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*------------------*
- * CPPLMAT3.C *
- * Hardware config *
- * Contd 2 *
- *------------------*/
-
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <dos.h>
- # include <fcntl.h>
- # include <bios.h>
- # include <stdlib.h>
- # include <SYS\stat.h>
- # include <conio.h>
- # include <alloc.h>
- # include <process.h>
- # include <ctype.h>
- # include <string.h>
-
- /* Global Variables */
- extern int x,y,z,i,j,k,l,m,n,bm,xm,ym,chx2,return2;
- extern int colour1,colour2,colour3,colour4,colour5,chif,background,colourprov,colourchoice;
- extern unsigned char c1,nc1[],trashcan[];
-
- /*-----------------------*
- * GET COLOUR 3 KEYBOARD *
- *-----------------------*/
- int get_colour3_keyboard()
- {
- j=get_key();
- /* If we typed between -1 and 4, it is OK else we search */
- if(j<5) return(j);
- /* If <Enter> the modifications are confirmed */
- if(c1==13) return(21);
- if((c1==67)||(c1==99)){
- /* If we want to change the choice : C c */
- chx2=1; return(21);
- }
- if((c1==79)||(c1==111)){
- /* If we want to confirm the change O o */
- chx2=2; return(21);
- }
- if((c1==81)||(c1==113)){
- /* If we want to quit without modifying Q q */
- chx2=3; return(21);
- }
- /* In the other cases we return 20 = no choice */
- return(20);
- }
- /*-------------------*
- * GET COLOUR3 MOUSE *
- *-------------------*/
- int get_colour3_mouse()
- {
- if((xm>3)&&(xm<46)&&(ym>3)&&(ym<11)){
- /* the mouse is in the colours zone */
- if(ym==4) colourprov=7;
- if(ym==6) colourprov=112;
- if(ym==8) colourprov=135;
- if(ym==10) colourprov=240;
- }
- if(ym==18){
- /* With the mouse it is choice and validation */
- if((xm>3)&&(xm<13)){
- /* Change the colour */
- chx2=1; return(21);
- }
- if((xm>13)&&(xm<29)){
- /* Confirm the modification */
- chx2=2; return(21);
- }
- if((xm>29)&&(xm<45)){
- /* Quit without changing */
- chx2=3; return(21);
- }
- }
- /* other cases : return 20 */
- return(20);
- }
- /*-----------------------*
- * DISPLAY CHOICE SCREEN *
- *-----------------------*/
- void display_choice_mono_screen()
- {
- /* Erase the zone that will be used */
- hide_the_mouse();
- textattr(15); window(2,3,59,24);
- clrscr(); window(1,1,80,25);
- /* Draw the grid */
- gotoxy(3,3); cputs("┌───┬─────────────────────────────────────────┐");
- gotoxy(3,4); cputs("│ 1 │ │");
- gotoxy(3,5); cputs("├───┼─────────────────────────────────────────┤");
- gotoxy(3,6); cputs("│ 2 │ │");
- gotoxy(3,7); cputs("├───┼─────────────────────────────────────────┤");
- gotoxy(3,8); cputs("│ 3 │ │");
- gotoxy(3,9); cputs("├───┼─────────────────────────────────────────┤");
- gotoxy(3,10); cputs("│ 4 │ │");
- gotoxy(3,11); cputs("└───┴─────────────────────────────────────────┘");
- gotoxy(3,17); cputs("╔═════════╤══════════════╤════════════════════╗");
- gotoxy(3,18); cputs("║ Choose │cOnfirm choice│ Quit without modif.║");
- gotoxy(3,19); cputs("╚═════════╧══════════════╧════════════════════╝");
- gotoxy(3,21); cputs(" Current colours. Your choice ( Keyboard or mouse ) ");
- /* And we fill it with a sentence in the right colour */
- textattr(7);
- gotoxy(8,4); cputs(" Text with colour choice number 1 ");
- textattr(112);
- gotoxy(8,6); cputs(" Text with colour choice number 2 ");
- textattr(135);
- gotoxy(8,8); cputs(" Text with colour choice number 3 ");
- textattr(240);
- gotoxy(8,10); cputs(" Text with colour choice number 4 ");
- show_the_mouse();
- }
- /*-----------------------------*
- * DISPLAY CHOICE MONO COLOURS *
- *-----------------------------*/
- void display_choice_mono_colour()
- {
- hide_the_mouse(); textattr(7);
- gotoxy(4,18); cputs(" Choose ");
- gotoxy(14,18); cputs(" cOnfirm choice");
- gotoxy(29,18); cputs(" Quit without modif. ");
- textattr(7); highvideo();
- gotoxy(5,18); cputs("C");
- gotoxy(16,18); cputs("O");
- gotoxy(30,18); cputs("Q");
- normvideo();
- /* Display this line with current colours */
- textattr(colourprov);
- gotoxy(3,21); cputs(" Current colours. Your choice ( Keyboard or mouse ) ");
- /* Outline the choice */
- textattr(135);
- if(chx2==1){
- gotoxy(4,18); cputs(" Choose ");
- }
- if(chx2==2){
- gotoxy(14,18); cputs(" cOnfirm choice ");
- }
- if(chx2==3){
- gotoxy(29,18); cputs(" Quit without modif. ");
- }
- show_the_mouse();
- }
- /*-----------------------*
- * CHANGE MONO COLOURS *
- *-----------------------*/
- void change_mono_colour()
- {
- textattr(colourprov+128);
- gotoxy(3,21); cputs(" Enter the new background colour, please. Your choice: ");
- gotoxy(57,21); c1=getch();
- z=get_colour2_keyboard();
- if(z==1) colourprov=7;
- if(z==2) colourprov=112;
- if(z==3) colourprov=135;
- if(z==4) colourprov=240;
- }
- /*----------------------*
- * CHOOSE MONO COLOUR *
- *----------------------*/
- void choose_mono_colour()
- {
- /* Update the new choice */
- display_colour_choice(); display_choice_mono_screen();
- chx2=1; load_temporary_colour();
- while(1){
- display_choice_mono_colour();
- while(1){
- if(kbhit()){
- /* If we pressed a key */
- c1=getch();
- if(c1==0){
- /* The key is coded in 2 bytes. Cut the 2nd one */
- c1=getch();
- return2=get_special_colour2(); break;
- }
- else{
- /* We pressed a key */
- return2=get_colour3_keyboard(); break;
- }
- }
- /* Else test the mouse */
- get_mouse_state();
- if(bm==1){
- /* We pressed a mouse button */
- return2=get_colour3_mouse(); break;
- }
- }
- /* We treat the result */
- if(return2==-1) return;
- if(return2==21){
- /* We confirmed or we pressed <Enter> to confirm */
- if(chx2==1){
- /* We want to change the colour */
- change_mono_colour();
- }
- if(chx2==2){
- /* We return after copying the colour value */
- copy_new_value_in_colour();
- return;
- }
- if(chx2==3){
- /* We return without changing the colour value */
- return;
- }
- }
- if(return2==22){
- /* F1 = On-line help */
- display_help("CONFIGUR",92,4,1); restore_help_screen();
- }
- }
- }
- /* End of the hardware config file */
-
-